import axios from '@/utils/request';
import { tokenName } from '@/config/settings';

export async function login(data) {
  return axios.http.request({
    url: '/login',
    method: 'post',
    data,
  });
}

export function getUserInfo(accessToken) {
  //此处为了兼容mock.js使用data传递accessToken，如果使用mock可以走headers
  return axios.http.request({
    url: '/userInfo',
    method: 'post',
    data: {
      [tokenName]: accessToken,
    },
  });
}

export function logout() {
  return axios.http.request({
    url: '/logout',
    method: 'post',
  });
}

export function register() {
  return axios.http.request({
    url: '/register',
    method: 'post',
  });
}
